package com.zzy.module.tikTok.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzy.common.entity.db.TikTokDaoEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author zhuZhaoYang
 * @date 2021/12/6 16:55
 */
@Mapper
public interface TikTokMapper extends BaseMapper<TikTokDaoEntity> {

    /**
     * 获取抖音链接列表
     *
     * @param page page
     * @return 抖音链接列表
     */
    @Select("select id,url,`desc`, mp4 from tiktok_girls")
    IPage<TikTokDaoEntity> getTikTokList(Page<TikTokDaoEntity> page);

    /**
     * 根据id获取抖音链接详情
     *
     * @param id 抖音链接ID
     * @return 抖音链接详情
     */
    @Select("select id,url,`desc`, mp4 from tiktok_girls where id=#{id} ")
    TikTokDaoEntity getTikTokById(Integer id);

    /**
     * 更新TikTok
     *
     * @param tikTokDaoEntity tikTokDaoEntity
     */
    @Update("update tiktok_girls set `desc`= #{desc} ,mp4=#{mp4} where id = #{id} ")
    void updateTikTok(TikTokDaoEntity tikTokDaoEntity);


    @Insert("insert into tiktok_girls( url, `desc`, mp4) values(#{url} ,#{desc} ,#{mp4} )")
    void myInsert(TikTokDaoEntity tikTokDaoEntity);
}

